<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>编辑轮播图</title>
<link rel="stylesheet" href="layui/css/layui.css" />
</head>
<body>
	<form class="layui-form"  style="margin-top: 20px;">
	<div class="layui-form-item" hidden="hidden">
			<label class="layui-form-label">轮播图ID</label>
			<div class="layui-input-inline">
				<input type="text" name="c_id" id="c_id" required
					lay-verify="required" class="layui-input" >
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">轮播图名称</label>
			<div class="layui-input-inline">
				<input type="text" name="c_name" id="c_name" required
					lay-verify="required" class="layui-input" >
			</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label">轮播图地址</label>
			<div class="layui-input-inline">
			 <button type="button" class="layui-btn layui-btn layui-btn-sm" id="test1">
					<i class="layui-icon">&#xe64a;</i>上传图片
				</button>
					<img id="imgFace"  style="width:120px" src=""/>
				<input type="text" name="c_pictaddr" id="c_pictaddr" required
					lay-verify="required" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">跳转地址</label>
			<div class="layui-input-inline">
				<input type="text" name="c_jumpaddr" id="c_jumpaddr" required
					lay-verify="required" class="layui-input">
			</div>
		</div>
		<div class="layui-btn-container" style="text-align: center;">
			<button class="layui-btn" lay-submit="" lay-filter="userEdit">修改</button>
		</div>
	</form>
	<script type="text/javascript" src="layui/layui.js"></script>
	<script>
	 layui.use(['form','upload'], function () {
		 var form = layui.form;
			var $ = layui.jquery;
		   var upload = layui.upload;
		 //执行实例
			  var uploadInst = upload.render({
			    elem: '#test1' //绑定元素
			    ,url: '/wk1un2_electricity_digital/UploadpictServlet?method=upload' //上传接口
			    ,acceptMine:'img/*'
			    ,done: function(res){
			      //上传完毕回调
			      console.log(res.code);
			      $("#c_pictaddr").val('upload/' + res.data);
			      $("#imgFace").css('display', 'block');
			      $("#imgFace").attr("src", "/wk1un2_electricity_digital/Backstage/upload/" + res.data);
			  layer.smg('新图片更新成功',{
				  icon:6,
				  time:1500
			  },function(){});
		 },
		 error: function(){
			      //请求异常回调
			 
			    }
			  });
			//监听提交
			form.on('submit(userEdit)', function(data) {
				var d = data.field;
				d.method = "updateCarousel";
				console.log(d);
				var url = '/wk1un2_electricity_digital/Backstage/updateCarousel';
				$.post(url, d, function(data) {
					if (data.count > 0) {
						console.log('修改成功');
						var index = parent.layer.getFrameIndex(window.name);
						parent.layer.close(index);
					}
				}, "json");
				return false;
			});
		});
	</script>
	

</body>
</html>